vcActionContainer
vcActionContainer is a container of vcAction objects used for storing, buffering, sending and receiving actions between resource clients, providers and brokers. Each vcActionContainer may fulfill multiple roles: - Providers are resources which perform actions. - Clients request Providers to perform actions. - Brokers connect Clients to Providers indirectly by routing action requests. How the actions are defined, handled, executed, and their properties interpreted are completely up to the Python scripts in each simulation. The implementation for methods in this class related to resource use, reservation, and work delegation can be overridden by registering corresponding callbacks.
See in: Overview
Module: vcBehaviors
Parent: vcBehavior
Children -
Referenced by: vcAction.ActionContainer, vcAction.From, vcAction.Receiver, vcAction.Sender, ... (see more)
vcAction.ActionContainer
vcAction.From
vcAction.Receiver
vcAction.Sender
vcAction.To
vcSimActionField.Actions
Properties
Learn how to use properties here. The properties are also inherited from the parent class.
| Name | Type | Access | Description |
| Actions | vcList[vcAction] | R | Gets a list of actions in container. |
| Brokers | vcList[vcActionContainer] | RW | Gets or sets the connected vcActionContainers that are considered to fulfill the "Broker" role by this container. |
| Clients | vcList[vcActionContainer] | RW | Gets or sets the connected vcActionContainers that are considered to fulfill the "Client" role by this container. |
| Connections | vcList | RW | Gets or sets list of Python script behaviors within component that will process received actions.See moreThe scripts should have a OnAction(action: vcAction) method, which gets called when an action is to be processed by this container. |
| NextFreeTime | Real | RW | Gets or sets the next available time this container is expected to be able to process actions. Expressed in simulation seconds. |
| OnResourceDo | object | RW | Gets or sets a callback function to override default behavior. |
| OnResourceRelease | object | RW | Gets or sets a callback function to override default behavior. |
| OnResourceReserve | object | RW | Gets or sets a callback function to override default behavior. |
| OnResourceStart | object | RW | Gets or sets a callback function to override default behavior. |
| OnResourceUse | object | RW | Gets or sets a callback function to override default behavior. |
| OnResourceWait | object | RW | Gets or sets a callback function to override default behavior. |
| PendingActionCount | Integer | R | Gets the number of pending actions. This is equivalent to len(PendingActions) but faster to execute. |
| PendingActions | vcList[vcAction] | R | Gets a list of pending action stored in the container.See moreThat is, actions that are received from other action containers and buffered for action processing. |
| Processing | Boolean | RW | Gets or sets a value indicating whether this container is executing actions. |
| Providers | vcList[vcActionContainer] | RW | Gets or sets the connected vcActionContainers that are considered to fulfill the "Provider" role by this container. |
| ReservedFor | vcActionContainer | RW | Gets or sets the vcActionContainer this container is reserved for. The value can be the container itself. |
Methods
Learn how to use methods here. The methods are also inherited from the parent class.
| Name | Return Type | Parameters | Description |
| clear | None | None | Deletes all vcActionContainer.Actions in this container. |
| clearPending | None | None | Deletes all vcActionContainer.PendingActions in this container. |
| createAction | vcAction | String actionName | Creates a new action to the Actions list and returns it.See moreParameters: actionName (str): Value to assign as vcAction.Name. Returns: vcAction: The created action. |
| createPendingAction | vcAction | String actionName | Creates a new action to the PendingActions list and returns it.See moreParameters: actionName (str): Value to assign as vcAction.Name. Returns: vcAction: The created action. |
| do | object | String actionType, Optional Keyword[timeout = Real], Optional Keyword[requestTemplate = vcAction], Optional Keyword[requestCustomizer = Callable] | Executes an action using this vcActionContainer and waits for its completion. Constructs and registers a request vcAction, and then calls either the OnResourceDo callback if it is defined, or the default implementation in vcHelpers.ResourceTools. See moreThis function returns an awaitable task. It must be awaited. Parameters: actionType (str): Value to assign as request vcAction.Name. Optional: timeout (float): Maximum amount of simulation time to wait for the action execution to start. Optional: requestTemplate (vcAction): Action to copy as template for the request. Optional: requestCustomizer (Callable[vcAction]): Callback that allows to edit the created request vcAction before it is sent. Returns: Awaitable[bool]: Task representing the operation. When awaited, returns a value indicating whether the action was performed within the timeout limit. Exceptions: ValueError: When requestCustomizer has incorrect function signature. RuntimeError: When this vcActionContainer hasn't been reserved. |
| moveAction | None | vcAction action, Integer index | Moves a given action to a new position in the Actions property list.See moreParameters: action (vcAction): The action object to move. index (int): 0-based desired position in the Actions list. Exceptions: IndexError: When the index is out of bounds of the Actions list. RuntimeError: When the action is not in the Actions list. |
| movePendingAction | None | vcAction action, Integer index | Moves a given action to a new position in the PendingActions property list.See moreParameters: action (vcAction): The action object to move. index (int): 0-based desired position in the PendingActions list. Exceptions: IndexError: When the index is out of bounds of the PendingActions list. RuntimeError: When the action is scheduled for deletion. RuntimeError: When the action is not in the PendingActions list. |
| popPending | vcAction | None | Removes the last action from the PendingActions list and returns that action. Returns: vcAction: The removed action or None if there are no pending actions. |
| popPending | vcAction | Integer index | Removes N:th from last action from the PendingActions list, and then returns that action.See moreParameters: index (int): 0-based index counted from the end of PendingActions list. Returns: vcAction: The removed action. Exceptions: IndexError: When the index is out of bounds. |
| release | Boolean | None | Releases the reservation of this container from the vcActionContainer defined in the ReservedFor property.See moreNotifies the vcActionContainer this resource was reserved by. Calls either the OnResourceRelease callback if it is defined, or the default implementation in vcHelpers.ResourceTools. Returns: bool: A value indicating whether the release was successful. |
| removePendingAction | Boolean | vcAction action | Tries to remove a given action from the PendingActions list and any other action containers it has been broadcast to.See moreRemoved actions are not deleted automatically, and failing to do so will result in a memory leak. Parameters: action (vcAction): The action object to remove. Returns: bool: True when action was found and removed, False otherwise. Exceptions: RuntimeError: When the action object has been scheduled for deletion. |
| reserve | object | String resourceFilter, Optional Keyword[actionType = String], Optional Keyword[timeout = Real], Optional Keyword[requestTemplate = vcAction], Optional Keyword[requestCustomizer = Callable] | Finds a connected vcActionContainer available to execute a specific action and reserves it. Waits for a resource to become available if necessary. Constructs and registers a request vcAction, and then calls either the OnResourceReserve callback if it is defined, or the default implementation in vcHelpers.ResourceTools. See moreThis function returns an awaitable task. It must be awaited. Parameters: resourceFilter (str): Substring that needs to appear in vcComponent.Name of the component that owns the resource vcActionContainer. Optional: actionType (str): Value to assign as request vcAction.Name. Optional: timeout (float): Maximum amount of simulation time to wait for a resource to become available. Optional: requestTemplate (vcAction): Action to copy as template for the request. Optional: requestCustomizer (Callable[vcAction]): Callback that allows to edit the created request vcAction before it is sent. Returns: Awaitable[vcActionContainer | None]: The task instance. When awaited, returns the reserved vcActionContainer or None if no resource was available within the timeout. Exceptions: ValueError: When requestCustomizer has incorrect function signature. |
| start | vcAction | String actionType, Optional Keyword[requestTemplate = vcAction], Optional Keyword[requestCustomizer = Callable] | Starts execution of an action in this container regardless if another action is still running. Generally, start() is used with the wait() method in order to catch when an action executed with start() has been completed. See moreConstructs and registers a request vcAction, and then calls either the OnResourceStart callback if it is defined, or the default implementation in vcHelpers.ResourceTools. Parameters: actionType (str): Value to assign as request vcAction.Name. Optional: requestTemplate (vcAction): Action to copy as template for the request. Optional: requestCustomizer (Callable[vcAction]): Callback that allows to edit the created request vcAction before it is sent. Returns: vcAction: The created request action. Exceptions: ValueError: When requestCustomizer has incorrect function signature. |
| use | object | String resourceFilter, String actionType, Optional Keyword[timeout = Real], Optional Keyword[requestTemplate = vcAction], Optional Keyword[requestCustomizer = Callable] | Finds a connected vcActionContainer available to execute a specific action and waits for its completion. Waits for a resource to become available if necessary. Constructs and registers a request vcAction, and then calls either the OnResourceUse callback if it is defined, or the default implementation in vcHelpers.ResourceTools. See moreThis function returns an awaitable task. It must be awaited. Parameters: resourceFilter (str): Substring that needs to appear in vcComponent.Name of the component that owns the resource vcActionContainer. actionType (str): Value to assign as request vcAction.Name. Optional: timeout (float): Maximum amount of simulation time to wait for a resource to become available. Optional: requestTemplate (vcAction): Action to copy as template for the request. Optional: requestCustomizer (Callable[vcAction]): Callback that allows to edit the created request vcAction before it is sent. Returns: Awaitable[bool]: Task representing the operation. When awaited, returns a value indicating whether a resource was found and reserved within the timeout limit. Exceptions: ValueError: When requestCustomizer has incorrect function signature. |
| wait | object | Optional Keyword[timeout = Real] | Waits until action called in start() method is completed.See moreThis function returns an awaitable task. It must be awaited. Parameters: Optional: timeout (float): Maximum simulation time in seconds to wait for action completion. Returns: Awaitable[bool]: Task representing the operation. When awaited, returns a value indicating whether the action was completed within the timeout limit. |